<?php
/*
	前端页面生成类
*/
namespace core;
defined('BY_JYA') or exit('error');
class made_page{
	private $pagevalue;
	
	public function made($htmls,$pagevalue='pagedata'){
		if(!$htmls || !is_array($htmls)){
			return '';
		}
		$this->pagevalue=$pagevalue;
		$this->root_windows=ROOT_D.'/core/resource/templates/';
		$this->root_windows_list_show=ROOT_D.'/core/resource/templates/list_shows/';
		$this->root_windows_list_edit=ROOT_D.'/core/resource/templates/list_edits/';
		$this->root_mobile=ROOT_D.'/core/resource/templates_mobile/';
		$method='made_'.$_SESSION['os'];
		return $this->$method($htmls);
	}
	public function made_windows($htmls){
		$default_html=$this->get_htmls_default_windows();
		$html_string='';
		$temp_string='';
		$flex='';
		if(!$htmls['0']){
			$htmls=array($htmls);
		}
		foreach($htmls as $key=>$html){
			$html=check_setting($default_html,$html);
			if($html['flex']){
				$flex='flex';
			}
			$method_name="made_windows_{$html['type']}";
			if(method_exists($this,$method_name)){
				$temp_string=$this->$method_name($html);
			}else{
				$temp_string=$this->made_windows_default($html);
			}
			$html_string.='<div class="col-jy" style="width:'.$html['width'].';">'.$temp_string.'</div>';
		}
		$html_string='<div class="'.$flex.'">'.str_replace('{pagevalue}',$this->pagevalue,$html_string) . '</div>';
		return $html_string;
	}
	public function made_windows_list($html){
		$html_string='';
		if($html['search']){
			$search_html='<div class="keyword-list-head"><div class="keyword-list-head clearfix">';
			foreach($html['search'] as $item){
				$temp=file_get_contents($this->root_windows.$item['type'].'.html');
				$item=$this->set_default($item,$this->get_template_default($item['type']));
				if($item['show']){
					$item['guanlians']=$this->guanlians($item['show'],$this->pagevalue.'params');
					unset($item['show']);
				}
				if(!$item['tovalue']){
					$item['tovalue']=$this->pagevalue.'.params';
				}
				$search_html.=$this->combile($item,$temp);
				
			}
			if($this->pagevalue=='modaldata'){
				$search_html.='<div class="form-group" ng-include="sys_html(\'common/modal_find\',true)"></div></div>';
			}else{
				$search_html.='<div class="form-group" ><div ng-include="sys_html(\'common/find\',true)"></div>';
				if($html['export']){
					$export_title=$htmls['export_title']?:'导出';
					$search_html.='<div class="pull-right">';
					$search_html.='<button class="btn btn-primary" ><a ng-href="{{export(\''.$html['export'].'\',pagedata.params)}}">'.$export_title.'</a></button>';
					$search_html.='</div>';
				}
				$search_html.='</div></div>';
			}
			$html_string.=$search_html;
		}
		if($html['search_one']){
			if($this->pagevalue=='modaldata'){
				$temp=file_get_contents($this->root_windows.'modal_search_one.html');
			}else{
				$temp=file_get_contents($this->root_windows.'search_one.html');
			}
			$html['search_one']=$this->set_default($html['search_one'],$this->get_template_default('search_one'));
			$html_string.=$this->combile($html['search_one'],$temp);
		}
		$html['list']=$this->set_default($html['list'],$this->get_template_default('list'));
		$list_html='';
		$list_head='';
		foreach($html['list']['list'] as $list){
			if($list['type']){
				$list=array($list);
			}
			$td_html='';
			foreach($list as $item){
				if($item['show']){
					$item['guanlians']=$this->guanlians($item['show'],'item');
					unset($item['show']);
				}
				if($item['set'] || (in_array($item['type'],array('href','modal','post')) && $item['name'])){
					$temp=file_get_contents($this->root_windows_list_edit.$item['type'].'.html');
				}else{
					$temp=file_get_contents($this->root_windows_list_show.$item['type'].'.html');
				}
				$td_html.=$this->combile($item,$temp);
				
			}
			$list_html.='<td>'.$td_html.'</td>';
			$list_head.='<th>'.$list[0]['title'].'</th>';
		}
		$html['list']['list']=$list_html;
		$html['list']['list_head']=$list_head;
		$action_html='';
		if($html['list']['action']){
			foreach($html['list']['action'] as $item){
				if($item['show']){
					$item['guanlians']=$this->guanlians($item['show'],'item');
					unset($item['show']);
				}
				if($item['set'] || (in_array($item['type'],array('href','modal','post')) && $item['name'])){
					$temp=file_get_contents($this->root_windows_list_edit.$item['type'].'.html');
				}else{
					$temp=file_get_contents($this->root_windows_list_show.$item['type'].'.html');
				}
				$action_html.=$this->combile($item,$temp);
			}
		}
		$html['list']['action']=$action_html;
		$html['list']['pagevalue']=$this->pagevalue;
		$list_temp=file_get_contents($this->root_windows.'list.html');
		$html_string.=$this->combile($html['list'],$list_temp);
		$html_string=str_replace(array('{pagevalue}','{key}'),array($this->pagevalue,$html['list']['key']),$html_string);
		return $html_string;
	}
	public function made_windows_edit($html){
		
		if(!$html['edits'] && $html['edit']){
			$html['edits']=array(
				array('title'=>$html['desc'],'list'=>$html['edit']),
			);
			unset($html['edit']);
		}
		if(!$html['edits']){
			return '';
		}
		$html_string='';
		$edit_tabs=array();
		$first_tab='';
		foreach($html['edits'] as $edit){
			if(!$edit['title']){
				$edit_html='<div class="form-horizontal modal-edit"><div class="modal-panel">';
			}else{
				if($html['edit_tab']){
					if(!$first_tab){
						$first_tab=$edit['title'];
					}
					$edit_tabs[]=$edit['title'];
					$edit_html='<div class="panel panel-default form-horizontal" ng-show="pagedata.active_edit_tab==\''.$edit['title'].'\'"><div class="panel-heading">'.$edit['title'].'</div><div class="panel-body">';
				}else{
					$edit_html='<div class="panel panel-default form-horizontal"><div class="panel-heading">'.$edit['title'].'</div><div class="panel-body">';
				}
			}
			foreach($edit['list'] as $item){
				
				$item=$this->set_default($item,$this->get_template_default($item['type']));
				if($item['type']=='array'){
					$list=$list_head='';
					$item['count']=count($item['list'])+1;
					foreach($item['list'] as $row){
						
						$temp=file_get_contents($this->root_windows_list_show.$row['type'].'.html');
						$list.='<td>'.$this->combile($row,$temp).'</td>';
						$list_head.='<th>'.$row['title'].'</th>';
					}
					$item['list']=$list;
					$item['list_head']=$list_head;
					$details='';
					foreach($item['details'] as $row){
						$row=$this->set_default($row,$this->get_template_default($row['type']));
						if($row['show']){
							$row['guanlians']=$this->guanlians($row['show'],'pagedata.current_field');
							unset($row['show']);
						}
						$row['tovalue']='pagedata.current_field';
						$temp=file_get_contents($this->root_windows.$row['type'].'.html');
						$details.=$this->combile($row,$temp);
					}
					$item['details']=$details;
				}
				if(!$item['tovalue']){
					$item['tovalue']=$this->pagevalue.'.item';
				}
				if($item['show']){
					$item['guanlians']=$this->guanlians($item['show'],$item['tovalue']);
					unset($item['show']);
				}
				$item['pagevalue']=$this->pagevalue;
				$temp=file_get_contents($this->root_windows.$item['type'].'.html');
				$edit_html.=$this->combile($item,$temp);
			}
			$edit_html.='</div></div>';
			$html_string.=$edit_html;
		}
		if($html['post']){
			if($html['post']=='modal_result'){
				if($html['result_field']){
					$html_string.='<div class="modal-sub"><button  class="btn btn-primary" ng-click="modal_result('.$this->pagevalue.'.item.'.$html['result_field'].')">提交</button></div>';
				}else{
					$html_string.='<div class="modal-sub"><button  class="btn btn-primary" ng-click="modal_result('.$this->pagevalue.'.item)">提交</button></div>';
				}
				
			}else{
				if($this->pagevalue=='modaldata'){
					$html_string.='<div class="modal-sub"><button  class="btn btn-primary" ng-click="modal_post('.$this->pagevalue.'.item,\''.$html['post'].'\')">提交</button></div>';
				}else{
					$html_string.='<div class="modal-sub"><button  class="btn btn-primary" ng-click="post('.$this->pagevalue.'.item,\''.$html['post'].'\')">提交</button></div>';
				}
				
			}
		}else{
			if($this->pagevalue=='modaldata'){
				$html_string.='<div class="modal-sub"><button  class="btn btn-primary" ng-click="modal_post('.$this->pagevalue.'.item,'.$this->pagevalue.'.op)">提交</button></div>';
			}else{
				$html_string.='<div class="modal-sub"><button  class="btn btn-primary" ng-click="post('.$this->pagevalue.'.item,'.$this->pagevalue.'.op)">提交</button></div>';
			}
		}
		if($html['edit_tab']){
			$edit_tabs=str_replace('"',"'",ijson_encode($edit_tabs));
			if($this->pagevalue=='modaldata'){
				$html_string='<ul class="nav nav-tabs" ng-init="modaldata.active_edit_tab=\''.$first_tab.'\'"><li ng-repeat="tab in '.$edit_tabs.'" ng-class="{\'active\':modaldata.active_edit_tab==tab}"><a href="javascript:;" ng-click="modaldata.active_edit_tab=tab">{{tab}}</a></li></ul>'.$html_string;
			}else{
				$html_string='<ul class="nav nav-tabs" ng-init="pagedata.active_edit_tab=\''.$first_tab.'\'"><li ng-repeat="tab in '.$edit_tabs.'" ng-class="{\'active\':pagedata.active_edit_tab==tab}"><a href="javascript:;" ng-click="pagedata.active_edit_tab=tab">{{tab}}</a></li></ul>'.$html_string;
			}
			
		}
		return $html_string;
	}
	public function made_windows_look($html){
		$html_string='';
		if($html['desc']){
			$html_string='<div class="panel panel-default form-horizontal"><div class="panel-heading">'.$html['desc'].'</div><div class="panel-body">';
		}else{
			$html_string='<div class="panel form-horizontal"><div class="panel-body">';
		}
		
		foreach($html['look'] as $item){
			if(!$item['tovalue']){
				$item['tovalue']=$this->pagevalue.'.item';
			}
			if($item['show']){
					$item['guanlians']=$this->guanlians($item['show'],$item['tovalue']);
					unset($item['show']);
			}
			$item['pagevalue']=$this->pagevalue;
			$temp=file_get_contents($this->root_windows.'edit_show/'.$item['type'].'.html');
			$html_string.=$this->combile($item,$temp);
		}
		$html_string.='</div></div>';
		return $html_string;
	}
	public function guanlians($show,$check){
		$guanlians=ijson_encode($show);
		$guanlians=str_replace('"',"'",$guanlians);
		$guanlians='ng-show="check_show('.$check.','.$guanlians.')"';
		return $guanlians;
	}
	public function made_mobile($htmls){
		$temp_string='';
		$html_string='<div class="fui-page fui-page-current"><div class="fui-header"><div class="fui-header-left" onclick="window.history.go(-1);"><a class="back"></a></div><div class="title">'.$htmls['title'].'</div><div class="fui-header-right"></div></div><div class="fui-content navbar">';
		foreach($htmls['list'] as $html){
			$method_name="made_mobile_{$html['type']}";
			if(method_exists($this,$method_name)){
				$temp_string=$this->$method_name($html);
			}else{
				$temp_string=$this->made_mobile_default($html);
			}
			$html_string.=$temp_string;
		}
		$html_string.='</div></div><div class="fui-navbar" ng-if="{pagevalue}.htmls.menu"><a href="javascript:;" ng-repeat="menu in {pagevalue}.htmls.menu.list" ng-click="access_json(menu.url)" class="external nav-item" ng-class="{\'active\':page.url==menu.url}"><span class="icon jinyunicon {{menu.icon}}" ng-style="{\'color\':{pagevalue}.htmls.menu.icon_color || \'#000000\'}"></span><span class="label" ng-style="{\'color\':{pagevalue}.htmls.menu.title_color || \'#000000\'}">{{menu.title}}</span></a></div>';
		$html_string=str_replace('{pagevalue}',$this->pagevalue,$html_string);
		return $html_string;
	}
	public function made_mobile_default($html){
		$temp=file_get_contents($this->root_mobile.$html['type'].'.html');
		$default=$this->get_template_default_mobile($html['type']);
		$html=$this->set_default($html,$default);
		if($html['show']){
			$html['guanlians']=$this->guanlians($html['show'],$this->pagevalue.'item');
			unset($html['show']);
		}
		if(!$html['tovalue']){
			$html['tovalue']=$this->pagevalue.'.item';
		}
		$html_string=$this->combile($html,$temp);
		return $html_string;
	}
	public function made_windows_default($html){
		$temp=file_get_contents($this->root_windows.$html['type'].'.html');
		$default=$this->get_template_default($html['type']);
		$html=$this->set_default($html,$default);
		
		if(!$html['tovalue']){
			$html['tovalue']=$this->pagevalue.'.item';
		}
		$html_string=$this->combile($html,$temp);
		return $html_string;
	}
	public function combile($data,$temp){
		if(!is_array($data) || empty($data)){
			return $temp;
		}
		
		foreach($data as $key=>$value){
			if(is_array($value)){
				$value=str_replace('"',"'",ijson_encode($value));
			}
			if($value===true){
				$value='true';
			}
			if($value===false){
				$value='false';
			}
			$temp=str_replace('{'.$key.'}',$value,$temp);
		}
		return $temp;
	}
	public function set_default($data,$default){
		if(!is_array($default) || empty($default)){
			return $data;
		}
		foreach($default as $key=>$value){
			if(is_array($value)){
				if(!$data[$key]){
					if($value[0]){
						$data[$key]=$value;
					}else{
						$data[$key]=array();
					}
				}else if($value[0]){
					//不分type处理方式
					foreach($data[$key] as &$value1){
						foreach($value['0'] as $key2=>$value2){
							if(!isset($value1[$key2])){
								if($value2==='bitian'){
									exi('生成页面时出错，关键参数未设置1！'.$key2,'error');
									
								}
								$value1[$key2]=$value2;
							}
						}
					}
				}else{
					//分type处理方式
					foreach($data[$key] as &$value1){
						if(!$value1[0]){
							if($value[$value1['type']]){
								foreach($value[$value1['type']] as $key2=>$value2){
									if(!isset($value1[$key2])){
										if($value2==='bitian'){
											exi('生成页面时出错，关键参数未设置2！'.$key2,'error');
										}
										$value1[$key2]=$value2;
									}
								}
							}
							
						}else{
							foreach($value1 as &$value11){
								if($value[$value11['type']]){
									foreach($value[$value11['type']] as $key2=>$value2){
										if(!isset($value11[$key2])){
											if($value2==='bitian'){
												exi('生成页面时出错，关键参数未设置3！'.$key2,'error');
											}
											$value11[$key2]=$value2;
										}
									}
								}
							}
						}
						
					}
				}
			}else{
				if(!isset($data[$key])){
					$data[$key]=$value;
				}
			}
		}
		return $data;
	}
	public function get_htmls_default_windows(){
		return array(
			'width'=>'100%',
		);
	}
	public function get_template_show_default(){
		return array(
			'string'=>array('data'=>'','title'=>'bitian'),
			'image'=>array('data'=>'','title'=>'bitian'),
			'plugins'=>array('name'=>'bitian','help'=>'','title'=>'','style'=>'1','pluginname'=>''),
		);
	}
	public function get_template_default($type=false){
		$defaults=array(
			'list'=>array('data'=>'bitian','tip'=>'','paixu'=>'none','paixu_op'=>'paixu','total'=>false,'psize'=>false,'pagelist'=>true,'delall'=>true,'del_one'=>true,'edit'=>true,'line_max_width'=>'300px','del_title'=>'删除','edit_op'=>'edit','key'=>'id','del_message'=>'确认删除吗？','del_op'=>'del','openvoice'=>false,'openvoice_action'=>'','list'=>array(
				'radio'=>array('name'=>'bitian','options'=>'bitian'),
				'select'=>array('name'=>'bitian','options'=>'bitian','option_title'=>'title','option_value'=>'id','option_color'=>'color'),
				'switch'=>array('name'=>'bitian','open_value'=>1,'close_value'=>0),
				'href'=>array('action'=>'','op'=>'','query'=>'','guanlians'=>'','html'=>'','plugin'=>'','shownew'=>''),
				'href_blank'=>array('action'=>'','op'=>'','query'=>'','guanlians'=>'','html'=>'','plugin'=>''),
				'modal'=>array('action'=>'','op'=>'','query'=>'','guanlians'=>'','html'=>'','plugin'=>''),
				'post'=>array('action'=>'','op'=>'','query'=>'','guanlians'=>'','plugin'=>'','message'=>'','hold'=>false),
				'image'=>array('name'=>'bitian'),
				'string'=>array('name'=>'bitian'),
				'string_open'=>array('name'=>'bitian','url'=>'bitian'),
				'unitstring'=>array('name'=>'bitian','help'=>''),
				'time_hour'=>array('name'=>'bitian','help'=>''),
				'img_string'=>array('img'=>'jy_nopic','data'=>array()),
				'credit'=>array('name'=>'bitian','help'=>''),
				'pay_submit'=>array('action'=>'','goback_url'=>'','guanlians'=>'','html'=>''),
				'select_item'=>array('name'=>'bitian','options'=>'bitian','option_title'=>'title','option_value'=>'id','selecttitle'=>'请选择'),
			),'action'=>array(
				'href'=>array('action'=>'','op'=>'','query'=>'','guanlians'=>'','html'=>'','plugin'=>''),
				'href_blank'=>array('action'=>'','op'=>'','query'=>'','guanlians'=>'','html'=>'','plugin'=>''),
				'href_item'=>array('action'=>'','op'=>'','query'=>'','guanlians'=>'','html'=>'','plugin'=>''),
				'modal'=>array('action'=>'','op'=>'','query'=>'','guanlians'=>'','html'=>'','plugin'=>''),
				'post'=>array('action'=>'','op'=>'','query'=>'','guanlians'=>'','plugin'=>'','message'=>'','hold'=>false),
				'modal_result'=>array('name'=>'bitian','title'=>'选取','title_field'=>'title','guanlians'=>''),
				'pay_submit'=>array('action'=>'','goback_url'=>'','guanlians'=>'','html'=>''),
			),'batch'=>array(
				'href'=>array('action'=>'','op'=>'','query'=>'','guanlians'=>'','html'=>'','plugin'=>''),
				'href_blank'=>array('action'=>'','op'=>'','query'=>'','guanlians'=>'','html'=>'','plugin'=>''),
				'modal'=>array('action'=>'','op'=>'','query'=>'','guanlians'=>'','html'=>'','plugin'=>''),
				'post'=>array('action'=>'','op'=>'','query'=>'','guanlians'=>'','plugin'=>'','message'=>'','hold'=>false),
				'modal_result'=>array('name'=>'bitian','title'=>'选取','title_field'=>'title','guanlians'=>''),
			)),
			'list_mobile'=>array('data'=>'list','empty_message'=>'列表为空','remark_field'=>'empty','key'=>'id','list_op'=>'','tabs'=>array(),'tab_field'=>'tab','text_fields'=>array(),'title_fields'=>array(),'action_r'=>array(
				'href'=>array('title'=>'bitian','url'=>'bitian','icon'=>''),
				'post'=>array('title'=>'bitian','op'=>'bitian','icon'=>''),
				'radio'=>array('title'=>'','op'=>'bitian','field'=>'bitian','value'=>'bitian','icon'=>''),
			),'action_l'=>array(
				'href'=>array('title'=>'bitian','url'=>'bitian','icon'=>''),
				'post'=>array('title'=>'bitian','op'=>'bitian','icon'=>''),
				'radio'=>array('title'=>'','op'=>'bitian','field'=>'bitian','value'=>'bitian','icon'=>''),
			)),
			'itemlist'=>array('data'=>'bitian','title'=>'','list'=>array()),
			'list_menu'=>array('num'=>12,'title'=>'','del'=>false,'del_message'=>'确定删除吗？','del_op'=>'del','menus'=>'bitian'),
			'data'=>array('num'=>12,'title'=>'','yuan'=>0,'one_num'=>6,'datas'=>'bitian','tpltype'=>0,'padding'=>0),
			'string'=>array('name'=>'bitian','help'=>'','read'=>false,'width'=>100),
			'copy'=>array('name'=>'bitian','help'=>''),
			'switch'=>array('name'=>'bitian','help'=>'','open_value'=>1,'close_value'=>0),
			'audio'=>array('name'=>'bitian','help'=>''),
			'checkbox'=>array('name'=>'bitian','help'=>'','options'=>'bitian','choose_all'=>false,'read'=>false,'no_lang'=>false),
			'checkbox_two'=>array('name'=>'bitian','help'=>'','options'=>'bitian','choose_all'=>false,'read'=>false,'no_lang'=>false),
			'checkbox_select'=>array('name'=>'bitian','help'=>'','options'=>'bitian','choose_all'=>false,'read'=>false,'select_title'=>'已选择','option_value'=>'id','option_title'=>'title','show_field'=>'uikhut7655gy','width'=>100),
			'color'=>array('name'=>'bitian','help'=>''),
			'colorpicker'=>array('name'=>'bitian','help'=>''),
			'day'=>array('name'=>'bitian','help'=>''),
			'icon'=>array('name'=>'bitian','help'=>'','from'=>''),
			'img_show'=>array('name'=>'bitian','help'=>'','width'=>''),
			'image'=>array('name'=>'bitian','help'=>'','read'=>false),
			'images'=>array('name'=>'bitian','help'=>''),
			'lat_lng'=>array('name'=>'bitian','help'=>''),
			'link'=>array('name'=>'bitian','help'=>'','from'=>'','from_page'=>''),
			'content'=>array('name'=>'bitian','help'=>'','from'=>'','from_page'=>''),
			'modal_search_one'=>array('name'=>'bitian','is_radio'=>false,'select_name'=>'','select_title'=>'请选择','add'=>true,'add_title'=>'添加','add_op'=>'edit','add_query'=>'','options'=>'','option_value'=>'id','option_title'=>'title','help'=>''),
			'password'=>array('name'=>'bitian','help'=>''),
			'pcd'=>array('name'=>'bitian','help'=>'','options'=>''),
			'pcd_address'=>array('name'=>'bitian','help'=>'','options'=>''),
			'radio'=>array('name'=>'bitian','help'=>'','options'=>'bitian','option_value'=>'value','read'=>false,'width'=>100),
			'search_one'=>array('placeholder'=>'请搜索名称','name'=>'bitian','is_radio'=>false,'select_name'=>'','select_title'=>'请选择','add'=>true,'add_title'=>'添加','add_op'=>'edit','add_query'=>'','options'=>'','option_value'=>'id','option_title'=>'title','help'=>''),
			'select'=>array('name'=>'bitian','help'=>'','options'=>'bitian','option_value'=>'id','option_title'=>'title','select_title'=>'请选择','width'=>100),
			'select_more'=>array('name'=>'bitian','help'=>'','options'=>'bitian','option_value'=>'id','option_title'=>'title','select_title'=>'请选择','width'=>100),
			'text'=>array('name'=>'bitian','help'=>'','read'=>false),
			'text_wx'=>array('name'=>'bitian','help'=>'','read'=>false),
			'richtext'=>array('name'=>'bitian','help'=>''),
			'time'=>array('name'=>'bitian','help'=>'','read'=>false,'time_type'=>'default'),
			'time_range'=>array('name'=>'bitian','read'=>false,'help'=>'','width'=>100),
			'time_hour'=>array('name'=>'bitian','read'=>false,'help'=>''),
			'time_onehour'=>array('name'=>'bitian','read'=>false,'help'=>''),
			'time_box'=>array('name'=>'bitian','help'=>''),
			'video'=>array('name'=>'bitian','thumb'=>'thumb','help'=>''),
			'list_image'=>array('data'=>'bitian','title'=>'title','del'=>true,'del_op'=>'del','image'=>'bitian','key'=>'id','help'=>''),
			'array'=>array('name'=>'bitian','title'=>'','tip'=>'','add_tip'=>'添加数据','show_detail'=>false,'list'=>array(
				'string'=>array('name'=>'bitian','title'=>'bitian'),
				'select'=>array('name'=>'bitian','title'=>'bitian','options'=>'bitian','option_value'=>'id','option_title'=>'title','select_title'=>'请选择'),
			)),
			'array_simple'=>array('name'=>'bitian','read'=>false,'noadd'=>false,'title'=>'','add_tip'=>'添加数据','show_detail'=>false,'default'=>'{}','fields'=>array(
				'string'=>array('name'=>'bitian','title'=>'bitian'),
				'time'=>array('name'=>'bitian','title'=>'bitian','max'=>''),
				'select'=>array('name'=>'bitian','title'=>'bitian','options'=>'bitian','option_value'=>'id','option_title'=>'title','select_title'=>'请选择'),
				'radio'=>array('name'=>'bitian','title'=>'bitian','options'=>'bitian','open_value'=>1,'close_value'=>0),
				'switch'=>array('name'=>'bitian','title'=>'bitian','open_value'=>1,'close_value'=>0),
			)),
			'array_look'=>array('name'=>'bitian','title'=>'','tip'=>''),
			'array_string'=>array('name'=>'bitian','value'=>'title','help'=>''),
			'specs'=>array('name'=>'bitian','help'=>''),
			'choose'=>array('name'=>'bitian','help'=>'','choose_title'=>'请选择','plugin'=>'','action'=>'','op'=>'','width'=>100,'read'=>false),
			'choose_up'=>array('name'=>'bitian','help'=>'','choose_title'=>'请选择','plugin'=>'','action'=>'','op'=>'','width'=>100),
			'choose_title'=>array('name'=>'bitian','help'=>'','choose_title'=>'请选择','plugin'=>'','action'=>'','op'=>'','width'=>100),
			'choose_many'=>array('name'=>'bitian','help'=>'','choose_title'=>'请选择','plugin'=>'','action'=>'','op'=>'','width'=>100,'option_image'=>'image','option_title'=>'title'),
			'edit_code'=>array('name'=>'bitian','help'=>'','code'=>'bitian','key'=>'id','del_one'=>true,'edit'=>true,'edit_op'=>'edit','del_op'=>'del'),
			'slider'=>array('name'=>'bitian','help'=>'','title'=>'','min'=>0,'max'=>100,'default'=>50,'step'=>1),
			'upfile'=>array('name'=>'bitian','help'=>'','ftype'=>'other'),
			'mobile_code'=>array('name'=>'bitian','help'=>'','mobile_name'=>'mobile','title'=>'','send_op'=>'bitian'),
			'ewm'=>array('width'=>'','help'=>'','show_wxapp_ewm'=>true,'show_wxwork_ewm'=>true),
			'hdps'=>array('title'=>'','help'=>''),
			'echarts'=>array('num'=>12,'height'=>350),
			'goodgroup'=>array('name'=>'bitian','help'=>'','options'=>'bitian','option_value'=>'id','option_title'=>'title','select_title'=>'请选择','pid_title'=>'请选择父类','cid_title'=>'请选择子类','width'=>100),
			'radio_tpl'=>array('name'=>'bitian','help'=>'','options'=>'bitian','option_value'=>'id','option_title'=>'title','option_image'=>'image','read'=>false),
			'string_two'=>array('name1'=>'bitian','name2'=>'bitian','title1'=>'','title2'=>'','unit1'=>'','unit2'=>'','help'=>'','read'=>false,'width'=>100),
			'array_string_much'=>array('name'=>'bitian','help'=>'','fields'=>'bitian','add_tip'=>'添加一项'),
			'string_much'=>array('name'=>'bitian','help'=>'','fields'=>'bitian'),
			'steps'=>array('steps'=>'bitian','step'=>1),
			'time_date'=>array('name'=>'bitian','help'=>'','read'=>false,'width'=>100),
			'unitstring'=>array('name'=>'bitian','read'=>false,'unit'=>'','help'=>''),
			'member_info'=>array('set'=>'','left_title'=>'余额','left_field'=>'credit2','left_submit'=>'','left_url'=>'','mid_url'=>'','avatar_field'=>'avatar','nick_field'=>'nickname','group_field'=>'group','group_url'=>'','right_title'=>'积分','right_field'=>'credit1','right_submit'=>'','right_url'=>''),
			'menu_list'=>array('list'=>array(array('url'=>'','title'=>'','icon'=>'','remark'=>''))),
			'submit_list'=>array('list'=>array(array('background'=>'#fff','title_color'=>'#ff5555','url'=>'','title'=>''))),
			'menu_tab'=>array('active_color'=>'red','list'=>array(array('url'=>'','title'=>''))),
			'menu'=>array('rownum'=>3,'background'=>'','list'=>array(array('url'=>'','title'=>'','img'=>'','color'=>''))),
			'guide_modal'=>array('tpltype'=>1),
			'href'=>array('url'=>'bitian','help'=>'','title'=>'bitian','btntitle'=>'点击'),
			'href_url'=>array('url'=>'bitian','help'=>'','title'=>'bitian','btntitle'=>'点击'),
			'plugins'=>array('name'=>'bitian','help'=>'','title'=>'','style'=>'1','pluginname'=>''),
			'modal'=>array('name'=>'bitian','btntitle'=>'点击','read'=>true,'help'=>''),
			'post'=>array('name'=>'bitian','action'=>'','op'=>'','query'=>'','guanlians'=>'','plugin'=>'','message'=>'','btntitle'=>'点击','read'=>true,'help'=>''),
		);
		if($type){
			return $defaults[$type];
		}else{
			return $defaults;
		}
	}
	public function get_template_default_mobile($type=false){
		$defaults=array(
			'head'=>array('style'=>1),
			'checkbox'=>array('name'=>'bitian','help'=>'','options'=>'bitian','choose_all'=>false),
			'day'=>array('name'=>'bitian','help'=>'','title'=>''),
			'image'=>array('name'=>'bitian','help'=>'','title'=>''),
			'image_code'=>array('name'=>'bitian','help'=>'','title'=>''),
			'pcd'=>array('name'=>'bitian','help'=>'','options'=>'','title'=>'','street'=>true),
			'radio'=>array('name'=>'bitian','help'=>'','options'=>'bitian','title'=>''),
			'select'=>array('name'=>'bitian','help'=>'','options'=>'bitian','option_value'=>'id','option_title'=>'title','select_title'=>'请选择'),
			'radio'=>array('name'=>'bitian','help'=>'','options'=>'bitian'),
			'string'=>array('name'=>'bitian','help'=>'','read'=>false,'title'=>''),
			'switch'=>array('name'=>'bitian','help'=>'','title'=>''),
			'text'=>array('name'=>'bitian','help'=>'','title'=>''),
			'time'=>array('name'=>'bitian','help'=>'','title'=>''),
			'member_info'=>array('set'=>'','left_title'=>'余额','left_field'=>'credit2','left_submit'=>'','left_url'=>'','mid_url'=>'','avatar_field'=>'avatar','nick_field'=>'nickname','group_field'=>'group','group_url'=>'','right_title'=>'积分','right_field'=>'credit1','right_submit'=>'','right_url'=>''),
			'menu_list'=>array('list'=>array(array('url'=>'','title'=>'','icon'=>'','remark'=>''))),
			'submit_list'=>array('list'=>array(array('background'=>'#fff','title_color'=>'#ff5555','url'=>'','title'=>''))),
			'menu_tab'=>array('active_color'=>'red','list'=>array(array('url'=>'','title'=>''))),
			'menu'=>array('rownum'=>3,'background'=>'','list'=>array(array('url'=>'','title'=>'','img'=>'','color'=>''))),
			'submit'=>array('title'=>'bitian','post'=>false,'data'=>'item','icon'=>'','url'=>'bitian'),
			'list'=>array('data'=>'list','empty_message'=>'列表为空','remark_field'=>'empty','key'=>'id','list_op'=>'','tabs'=>array(),'tab_field'=>'tab','text_fields'=>array(),'title_fields'=>array(),'action_r'=>array(
				'href'=>array('title'=>'bitian','url'=>'bitian','icon'=>''),
				'post'=>array('title'=>'bitian','op'=>'bitian','icon'=>''),
				'radio'=>array('title'=>'','op'=>'bitian','field'=>'bitian','value'=>'bitian','icon'=>''),
			),'action_l'=>array(
				'href'=>array('title'=>'bitian','url'=>'bitian','icon'=>''),
				'post'=>array('title'=>'bitian','op'=>'bitian','icon'=>''),
				'radio'=>array('title'=>'','op'=>'bitian','field'=>'bitian','value'=>'bitian','icon'=>''),
			)),
			
		);
		if($type){
			return $defaults[$type];
		}else{
			return $defaults;
		}
	}
}